package com.ruoyi.web.core.config;

import org.springframework.ai.chat.ChatClient;
import org.springframework.ai.openai.OpenAiChatClient;
import org.springframework.ai.openai.api.OpenAiApi;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class OpenAiConfig {

   @Value("${spring.ai.openai.base-url}")
   private String baseUrl;

   @Value("${spring.ai.openai.api-key}")
   private String token;

   @Bean
   public ChatClient chatClient() {
      OpenAiApi openAiApi = new OpenAiApi(baseUrl, token);
      ChatClient chatClient = new OpenAiChatClient(openAiApi);
      return chatClient;
   }
}
